{extend name="base" /} {block name="css"}
{/block} {block name="body"}
<link rel="stylesheet" href="__ADMIN__/plugins/wangEditor/css/wangEditor.min.css">
<style type="text/css">
    .wangEditor-menu-container .menu-item a {
        padding: 12px 0;
    }

    .wangEditor-menu-container .menu-item {
        height: 37px;
        width: 37px;
    }

    .wangEditor-menu-container .menu-group {
        padding: 0;
    }

    .wangEditor-container {
        border: 1px solid #e6e6e6;
    }

    .coverBox {
        position: absolute;
        right: 25px;
        bottom: 30px;
        z-index: 1000;
        background: #fff;
        height: 300px;
        width: 450px;
    }

    .coverBox span {
        position: absolute;
        background: rgba(10, 10, 10, .4);
        padding: 5px;
        bottom: 1px;
        cursor: pointer;
        font-size: 10px;
        color: #ffffff;
    }

    .coverBox img {
        width: 100%;
        height: 100%;
    }

    .coverBox .recheck {
        right: 1px;
    }

    .coverBox .removeCove {
        left: 1px;
    }
</style>
<!--tab标签-->
<div class="layui-tab-brief">

    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <form class="layui-form form-container" data-url="{:url('admin/article/save')}"
                  localtion-url="{:url('admin/article/index')}">

                <div class="layui-form-item">
                    <label class="layui-form-label">标题</label>
                    <div class="layui-input-block">
                        <input type="text" id="L_title" name="title" value="" required=""
                               lay-verify="required" autocomplete="off" class="layui-input"/>
                    </div>
                </div>
                <div class="layui-row layui-col-space15 layui-form-item">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">颜色</label>
                        <div class="layui-input-block">
                            <span id="colorSelect" style="display: block;float:left"></span>
                            <input id="color" name="color" type="text" value="" class="layui-input"
                                   style="display: block;float:left;width: 100px"/>
                            </span>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label  class="layui-form-label">外链</label>
                        <div class="layui-input-block">
                            <input name="out_link" type="text" value=""
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">结束时间<a title="一般用于活动线报和广告">
                            <i class="layui-icon layui-icon-tips"></i>
                        </a></label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="activity_finish_time" id="activity_finish_time">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">内容</label>
                    <div class="layui-input-block">
                        <textarea id="textarea" name="content" style="height:300px;width: 100%;"></textarea>
                    </div>
                </div>

                <div class="layui-row layui-col-space15 layui-form-item">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">资源分类</label>
                        <div class="layui-input-block">
                            <select lay-verify="required" name="category_id" lay-filter="tid">
                                {volist name="$category_level_list" id="vo"}
                                <option  value="{$vo.id}">{neq name="vo.level" value="1"}|{php}for($i=1;$i<$vo['level'];$i++){echo '--';}{/php}{/neq}{$vo.name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label  class="layui-form-label">关键字</label>
                        <div class="layui-input-block">
                            <input name="keywords" type="text" value="" placeholder="英文逗号分隔"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">定时发布<a title="点击查看使用方法" target="_blank" href="http://www.laysns.com/thread/2479.html">
                            <i class="layui-icon layui-icon-tips"></i>
                        </a></label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="publish_time" id="publish_time" value="">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">描述</label>
                    <div class="layui-input-block">
                        <textarea name="description" placeholder="内容提要" class="layui-textarea fly-editor" style="height: 60px;"></textarea>
                    </div>
                </div>
                <div class="layui-row layui-col-space15 layui-form-item">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">附件后缀</label>
                        <div class="layui-input-block">
                            <input name="attachment_ext" type="text"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label  class="layui-form-label">附件大小(M)</label>
                        <div class="layui-input-block">
                            <input name="attachment_size" type="text"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">

                    <label class="layui-form-label">封面</label>
                    <div class="layui-input-inline" style="width: auto;margin-right:0px">
                        <button type="button" class="layui-btn" id="image">
                            <i class="layui-icon">&#xe67c;</i>上传图片
                        </button>
                    </div>
                    <div class="layui-input-inline" style="width: calc(100% - 300px);">
                        <input type="text" id="cover_img" name="cover_img"  class="layui-input">
                    </div>
                    <div class="coverBox" hidden >
                        <img src="__ADMIN__/images/default.png" alt="">
                    </div>
                    <div class="layui-input-inline" style="width: 20px;" id="viewCoverPic">

                        <a class="layui-btn layui-btn-primary" >预览</a>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">附件一</label>
                    <div class="layui-input-inline" style="width: auto;margin-right:0px">
                        <button type="button" class="layui-btn layui-btn-normal" id="link1">
                            <i class="layui-icon">&#xe67c;</i>上传附件
                        </button>
                    </div>
                    <div class="layui-input-inline" style="width: calc(100% - 300px);">
                        <input type="text" name="down_link1" class="layui-input">
                    </div>
                    <!--                    <div class="layui-input-inline" style="width: 20px;">-->
                    <!--                        <a class="layui-btn layui-btn-primary downBtn">下载</a>-->
                    <!--                    </div>-->
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">附件二</label>
                    <div class="layui-input-inline" style="width: auto;margin-right:0px">
                        <button type="button" class="layui-btn layui-btn-normal"  id="link2">
                            <i class="layui-icon">&#xe67c;</i>上传附件
                        </button>
                    </div>
                    <div class="layui-input-inline" style="width: calc(100% - 300px);">
                        <input type="text"  name="down_link2"  class="layui-input">
                    </div>
                    <!--                    <div class="layui-input-inline" style="width: 20px;">-->
                    <!--                        <a class="layui-btn layui-btn-primary downBtn">下载</a>-->
                    <!--                    </div>-->
                </div>


                <div class="layui-form-item">



                </div>
                <input type="hidden" name="status" value="1">
                <div class="btable-paged">
                    <div class="formbtngroup">

                        <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="formadd">提交</button>
                        <button onclick="history.go(-1);return false;" class="layui-btn layui-btn-primary layui-btn-sm">
                            返回
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
{/block} {block name="js"}
<script type="text/javascript" src="__ADMIN__/js/formadd.js"></script>
<script type="text/javascript" src="__ADMIN__/plugins/wangEditor/js/wangEditor.min.js"></script>
<script type="text/javascript">
    var editor = new wangEditor('textarea');
    editor.config.uploadImgUrl = '{:url("system/doUploadPic")}';
    editor.config.uploadImgFileName = 'FileName';

    editor.config.menus = $.map(wangEditor.config.menus, function (item, key) {
        if (item === 'eraser') {
            return null;
        }
        if (item === 'video') {
            return null;
        }
        if (item === 'location') {
            return null;
        }
        return item;
    });
    if($(window).width()<1000){
        editor.config.menus = ['bold', 'fontsize', 'forecolor', 'link', 'unlink','img', 'fullscreen'];
    }
    editor.config.pasteText = false;
    editor.create();


    layui.use(['form', 'colorpicker','upload'], function () {
        var form = layui.form,
            colorpicker = layui.colorpicker,
            upload = layui.upload,
            jq = layui.jquery;

        //渲染
        colorpicker.render({
            elem: '#colorSelect'  //绑定元素
            , done: function (color) {
                jq('#color').val(color);
                console.log(color)
                //譬如你可以在回调中把得到的 color 赋值给表单
            }
        });
        var uploadImg = jq("#image");
        upload.render({
            elem: '#image',
            url: "{:url('upload/upimage')}",
            done: function (res) {
                if (res.code == '0') {
                    jq('input[name=cover_img]').val(res.data.src);
                    return layer.msg('上传成功');
                } else {

                    return layer.msg(res.msg);
                }

            }
        });

        upload.render({
            elem: '#link1',
            url: "{:url('index/upload/upfile2')}",
            accept: 'file',
            done: function (res) {
                if (res.code == '0') {
                    jq('input[name=down_link1]').val(res.data.src);
                    return layer.msg('上传成功');
                } else {

                    return layer.msg(res.msg);
                }

            }
        });
        upload.render({
            elem: '#link2',
            accept: 'file',
            url: "{:url('index/upload/upfile2')}",
            done: function (res) {
                if (res.code == '0') {
                    jq('input[name=down_link2]').val(res.data.src);
                    return layer.msg('上传成功');
                } else {

                    return layer.msg(res.msg);
                }

            }
        });

        jq('#viewCoverPic').hover(function () {
            var box = $("div.coverBox");
            if (jq('#cover_img').val().length>10){
                box.fadeIn(200);   box.find("img")[0].src=jq('#cover_img').val();
            }
        },function () {
            jq("div.coverBox").fadeOut(100)
        });
    });
</script>
{/block}